using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "FriendMinHpRandomTarget-获得随机的这个棋子的受伤的友方", menuName = "Skill/Target/FriendMinHpRandomTarget-获得随机的这个棋子的受伤的友方")]
public class FriendMinHpRandomTarget : TargetSelectorBase
{
    public override List<Chess> SelectTargets(Chess chess, GameEvent e)
    {
        var list = new List<Chess>();
        var chessList = ChessManager.GetInstance().chessList;
        foreach (var c in chessList)
        {
            if(c.GetChessSide() != chess.GetChessSide()) continue;
            if (c.ChessDetail.Health != c.ChessDetail.OriginalHp )
            {
                list.Add(c);
            }
        }

        if (list.Count == 0)
        {
            return list;
        }

        var g= list[Random.Range(0, list.Count)];
        list.Clear();
        list.Add(g);
        return list;
    }
}